/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.khk.lesson;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Jeroen
 */
public class BestemmingController {

    private Integer id;
    private String bestemming;
    private Continent continentID;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getBestemming() {
        return bestemming;
    }

    public void setBestemming(String bestemming) {
        this.bestemming = bestemming;
    }

    public Continent getContinentID() {
        return continentID;
    }

    public void setContinentID(Continent continentID) {
        this.continentID = continentID;
    }
    
    
      public Bestemming getBestemmingById(Integer id){
        
        EntityManagerFactory emf = null;
        try {
            emf = Persistence.createEntityManagerFactory("Awesome_RD_TravelshopPU");
//let op: gebruik hier de juiste naam van de persistence unit 
//(zoek op in persistence.xml)

           EntityManager em2 = emf.createEntityManager();
            Bestemming bestemming = (Bestemming)em2.createNamedQuery("Bestemming.findById").setParameter("id", id).getSingleResult();
            return bestemming;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            emf.close();
            
        }
    }
    
    
    
    
    
    
    
    
}
